import { signUser } from '@/api/api';
export default {
    namespaced: true,
    state: () => ({
        token: window.localStorage.vuex ? JSON.parse(window.localStorage.vuex).user.token : '',
    }),
    mutations: {
        changeToken(state, payload) {
            //同步方法，存储到仓库
            debugger
            state.token = payload;
        },
    },
    actions: {
        // ctx={} 发起请求
        async getToken({ commit, state }, params) {
            debugger
            let res = await signUser(params);
            if (res.status == 200) {
                //更改状态
                debugger
                commit('changeToken', res.data.token);
                return res;
            }
        },
    },
};